<template>
    <div >

        <el-table
                :data="tableData"
                border
                style="width: 100%">
            <el-table-column
                    fixed
                    prop="id"
                    label="编号"
                    width="60">
            </el-table-column>

            <el-table-column
                    prop="name"
                    label="姓名"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="college"
                    label="学院"
                    width="100">
            </el-table-column>

            <el-table-column
                    prop="category"
                    label="获奖类别"
                    width="200">
            </el-table-column>

            <el-table-column
                    prop="award"
                    label="比赛名称"
                    width="250">
            </el-table-column>


            <el-table-column
                    prop="ranking"
                    label="工号"
                    width="100">
            </el-table-column>
            <el-table-column
                    prop="charge"
                    label="完成人"
                    width="120">
            </el-table-column>

            <el-table-column
                    prop="achievement"
                    label="基本绩点"
                    width="120">
            </el-table-column>

            <el-table-column
                    prop="gpa"
                    label="获得绩点"
                    width="100">
            </el-table-column>

            <el-table-column
                    fixed="right"
                    label="操作"
                    width="100">
                <template slot-scope="scope">
                    <el-button @click="edit(scope.row)" type="text" size="small">修改</el-button>
                    <el-button @click="deleteTeacher(scope.row)" type="text" size="small">删除</el-button>
                </template>
            </el-table-column>


        </el-table>
        <el-pagination
                background
                layout="prev, pager, next"
                page-size="6"
                :total="total"
                @current-change="page">
        </el-pagination>
    </div>
</template>

<script>
    export default {
        name:"InsManage",
        methods: {
            deleteTeacher(row){
                this.$axios.delete('/ins/deleteById/'+row.id).then(resp =>{
                    this.$message({
                        showClose: true,
                        message: '删除成功',
                        type: 'success',
                    });
                    window.location.reload()
                })
            },
            edit(row) {
                this.$router.push({
                    path:'/sys/update',
                    query:{
                        id:row.id
                    }
                })
            },
            page(currentPage){
                const  _this =this
                this.$axios.get('/ins/findAll/'+currentPage+'/6').then(resp =>{
                    _this.tableData = resp.data.content
                    _this.total =resp.data.totalElements
                    _this.pageSize=resp.data.totalElements



                })
            }},

        created() {
            const  _this =this
            this.$axios.get('/ins/findAll/1/6').then(function (resp){
                _this.tableData = resp.data.content
                _this.total =resp.data.totalElements
                _this.pageSize=resp.data.totalElements

                //token验证
                //_this.JSON.parse(window.localStorage.getItem('access-admin'))

            })

        },

        data() {
            return {
                admin:'',
                total:null,
                tableData: null
            }
        }
    }
</script>


<style scoped>

</style>